import { request } from "../utils";
import config from "../config";
export default {
  login,
  register,
  getVerifyCode,
  logout,
};

// 登录
async function login({
  app_id,
  verify_field,
  verify_type,
  mobile,
  email,
  password,
  verify_code_id,
  code,
}) {
  const res = await request({
    url: config.SERVER_URL + "/auth/login",
    method: "POST",
    data: {
      app_id,
      verify_field,
      verify_type,
      mobile,
      email,
      password,
      verify_code_id,
      code,
    },
  });

  return res;
}
// 登录
async function register({
  app_id,
  verify_field,
  email,
  mobile,
  verify_code_id,
  code,
  password,
  identity_type,
}) {
  const res = await request({
    url: config.SERVER_URL + "/auth/register",
    method: "POST",
    data: {
      app_id,
      verify_field,
      email,
      mobile,
      verify_code_id,
      code,
      password,
      identity_type,
    },
  });

  return res;
}
// 登录
async function getVerifyCode({ app_id, verify_field, email, mobile, scene }) {
  const res = await request({
    url: config.SERVER_URL + "/auth/verify-code",
    method: "POST",
    data: {
      app_id,
      verify_field,
      email,
      mobile,
      scene,
    },
  });

  return res;
}

async function logout() {
  const res = await request({
    url: config.SERVER_URL + "/auth/logout",
    method: "POST",
  });

  return res;
}
